<template>
    <div class="courses-erji-nav">
        <el-menu :default-active="activeIndex" class="el-menu-demo"  mode="horizontal" :router="true" v-if="roleId == 'TEACHER' || roleId == 'MARKET_TEACHER' ||  roleId == 'UNIVERSITY_TEACHER'">
            <el-menu-item index="/Teaching/Course/CreativeCourse/Experiment/CourseTemplate">课程模板</el-menu-item>
            <el-menu-item index="/Teaching/Course/CreativeCourse/Experiment/MirrorManage">镜像管理</el-menu-item>
        </el-menu>
        <el-menu :default-active="activeIndex" class="el-menu-demo"  mode="horizontal" :router="true" v-if="roleId == 'ADMIN' || roleId == 'INTERNET_ADMIN' || roleId == 'SUPER_ADMIN'">
            <el-menu-item index="/Admin/CreativeCourse/Experiment/CourseTemplate">课程模板</el-menu-item>
            <el-menu-item index="/Admin/CreativeCourse/Experiment/MirrorManage">镜像管理</el-menu-item>
        </el-menu>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                activeIndex: '',
                roleId:''
            }
        },
        created() {
            let self = this
            self.roleId = self.$store.state.user.roles[0]
            self.fetchDate()
        },
        methods: {
            fetchDate() {
                let self = this
                if(self.roleId == 'TEACHER' || self.roleId == 'MARKET_TEACHER' || self.roleId == 'UNIVERSITY_TEACHER'){
                    var cur_path = self.$route.matched[4].path //获取当前路由
                    self.activeIndex = cur_path
                }else if(self.roleId == 'ADMIN' || self.roleId == 'INTERNET_ADMIN' || self.roleId == 'SUPER_ADMIN'){
                    var cur_path = self.$route.matched[3].path //获取当前路由
                    self.activeIndex = cur_path
                }

            },
            handleSelect(key, keyPath) {
                console.log(key, keyPath)
            }
        },
        watch: {
            "$route": "fetchDate"
		}
    }
</script>

